package com.paradise.ytj.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.paradise.ytj.activity.SplashActivity;
import com.paradise.ytj.bean.Constant;
import com.paradise.ytj.service.IncommingService;
import com.paradise.ytj.utils.SpUtils;


/**
 * Created by Administrator on 2017/8/27 0027.
 */

public class BootBroadcastReceiver extends BroadcastReceiver {
    //重写onReceive方法
    @Override
    public void onReceive(Context context, Intent intent) {
        //启动应用，参数为需要自动启动的应用的包名
        boolean launch = SpUtils.getBoolean(context, Constant.LAUNCH_NAME, Constant.LAUNCH_DEFAULT);
        if (launch) {
            Intent mBootIntent = new Intent(context, SplashActivity.class);
            // 下面这句话必须加上才能开机自动运行app的界面
            mBootIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(mBootIntent);

            Intent intent2 = new Intent(context, IncommingService.class);
            context.startService(intent2);
        }
    }
}
